Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
The 'timed-out' npm package is used to timeout HTTP requests. It provides a simple way to set timeouts for various stages of an HTTP request, such as the connection, socket, and response stages.
Set timeout for HTTP request
This feature allows you to set a timeout for an HTTP request. In this example, a timeout of 5 seconds is set for the HTTP GET request to 'http://example.com'. If the request takes longer than 5 seconds, it will be aborted.
const http = require('http');
const timedOut = require('timed-out');
const req = http.get('http://example.com', (res) => {
// Handle response
});
// Set a timeout of 5 seconds
const timeout = 5000;
timedOut(req, timeout);
Set timeout for specific stages
This feature allows you to set timeouts for specific stages of an HTTP request. In this example, different timeouts are set for the connection, socket, and response stages of the HTTP GET request to 'http://example.com'.
const http = require('http');
const timedOut = require('timed-out');
const req = http.get('http://example.com', (res) => {
// Handle response
});
// Set timeouts for different stages
const options = {
connect: 1000, // 1 second for connection
socket: 2000, // 2 seconds for socket
response: 3000 // 3 seconds for response
};
timedOut(req, options);
Axios is a promise-based HTTP client for the browser and Node.js. It allows you to set timeouts for requests and provides a more comprehensive set of features for making HTTP requests compared to 'timed-out'.
Request is a simplified HTTP client that supports timeouts and many other features. It is more feature-rich than 'timed-out' and provides a higher-level API for making HTTP requests.
Got is a human-friendly and powerful HTTP request library for Node.js. It supports timeouts and provides a more modern and flexible API compared to 'timed-out'.
Timeout HTTP/HTTPS requests
Emit Error object with code
property equal ETIMEDOUT
or ESOCKETTIMEDOUT
when ClientRequest is hanged.
var get = require('http').get;
var timeout = require('timed-out');
var req = get('http://www.google.ru');
timeout(req, 2000); // Set 2 seconds limit
Required
Type: ClientRequest
The request to watch on.
Required
Type: number
or object
Time in milliseconds to wait for connect
event on socket and also time to wait on inactive socket.
Or you can pass Object with following fields:
connect
- time to wait for connectionsocket
- time to wait for activity on socketMIT © Vsevolod Strukchinsky
FAQs
Timeout HTTP/HTTPS requests
The npm package timed-out receives a total of 2,673,774 weekly downloads. As such, timed-out popularity was classified as popular.
We found that timed-out demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.